

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
    <style>
    /* base */
    html,
    body,
    .container {
      width: 100%;
      height: 100%;
    }

    a,
    a:link,
    a:visited {
      text-decoration: none;
      color: inherit;
    }

    ul {
      list-style: none;
    }

    *,
    ::before,
    ::after {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    *:focus {
      outline: 0;
    }

    .container {
      display: flex;
      padding-top: 20px;
    }

    /* Nav */
    .container .doc-nav {
      position: fixed;
      height: 100%;
      margin: 0 30px 0 40px;
      width: 280px;
    }

    .doc-nav .nav-header {
      display: flex;
      align-items: center;
      box-sizing: border-box;
      background-color: rgb(240, 241, 242);
      height: 40px;
      padding: 16px;
      font-size: 18px;
      font-weight: 500;
      color: rgb(62, 64, 66);
      cursor: pointer;
    }

    .doc-nav .nav-content {
      height: calc(100% - 40px);
      overflow-y: auto;
      color: rgb(32, 34, 36);
    }

    .doc-nav .nav-content .nav-list,
    .doc-nav .nav-content .nav-sub-list {
      line-height: 1.5rem;
    }

    .doc-nav .nav-content .nav-label {
      display: inline-block;
      position: relative;
      padding: 2px 0 2px 20px;
      margin-bottom: 4px;
    }

    .doc-nav .nav-content .nav-sub-label {
      position: relative;
      padding: 2px 0 2px 40px;
      font-size: 14px;
    }

    .doc-nav .nav-content .nav-sub-label:hover {
      text-decoration: underline;
    }

    .doc-nav .nav-content .nav-list .nav-label.group::before {
      border-bottom: 0.25rem solid transparent;
      border-left: 0.25rem solid #6e7072;
      border-right: 0;
      border-top: 0.25rem solid transparent;
      content: '';
      display: block;
      height: 0;
      left: 0.5rem;
      position: absolute;
      top: 0.625rem;
      transition: transform 0.1s linear;
      width: 0;
    }

    .doc-nav .nav-content .nav-list .nav-label.group.active::before {
      transform: rotate(90deg);
    }

    /* doc content */
    .container .doc-content {
      position: fixed;
      height: 100%;
      width: calc(100% - 80px - 40px - 30px - 240px);
      right: 0%;
      overflow-y: auto;
    }

    .doc-title {
      border-bottom: 1px solid #dcdee0;
      font-size: 22px;
      margin: 8px 0 0;
      padding-bottom: 16px;
    }

    .doc-content h3 {
      font-size: 24px;
      font-weight: 600;
      margin: 24px 0;
    }

    .doc-content h4 {
      font-size: 22px;
      font-weight: 500;
      margin: 30px 0 8px;
    }

    .doc-content h4 span {
      color: #007d9c;
    }

    .doc-content .doc-declare {
      background-color: #fafafa;
      border-radius: 5px;
      border: 1px solid #ccc;
      font-size: 14px;
      overflow-x: auto;
      padding: 10px;
      tab-size: 4;
      line-height: 20px;
    }

    .doc-content .doc-comment {
      font-size: 16px;
      margin: 16px 0;
      line-height: 24px;
      word-break: break-word;
    }
  </style>

</head>
<body>
  <div class="container">
    <div class="doc-nav">
      <a href="#Documentation" class="nav-header">Documentation</a>
      <nav class="nav-content">
        <ul class="nav-list">
          <li>
            <a href="#includes" class="nav-label">Includes</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#tuya_cloud_types.h" class="nav-sub-label">tuya_cloud_types.h</a>
              </li>
      

              <li>
                <a href="#httpc.h" class="nav-sub-label">httpc.h</a>
              </li>
      

              <li>
                <a href="#tuya_hal_mutex.h" class="nav-sub-label">tuya_hal_mutex.h</a>
              </li>
      
            </ul>
            
          </li>
          <li>
            <a href="#macros" class="nav-label">Macros</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#__HTTP_MANAGER_H_" class="nav-sub-label">__HTTP_MANAGER_H_</a>
              </li>
      

              <li>
                <a href="#MAX_HTTP_SESSION_NUM" class="nav-sub-label">MAX_HTTP_SESSION_NUM</a>
              </li>
      

              <li>
                <a href="#INVALID_HTTP_SESSION_ID" class="nav-sub-label">INVALID_HTTP_SESSION_ID</a>
              </li>
      

              <li>
                <a href="#MAX_HTTP_URL_LEN" class="nav-sub-label">MAX_HTTP_URL_LEN</a>
              </li>
      
            </ul>
            
          </li>
          <li>
            <a href="#functions" class="nav-label">Functions</a>
            
            <ul class="nav-sub-list">
            
            </ul>
            
          </li>
          <li>
            <a href="#vars" class="nav-label">Vars</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#S_HTTP_MANAGER" class="nav-sub-label">S_HTTP_MANAGER</a>
              </li>
      
            </ul>
            
          </li>
          <li>
            <a href="#consts" class="nav-label">Consts</a>
            
            <ul class="nav-sub-list">
            
            </ul>
            
          </li>
          <li>
            <a href="#types" class="nav-label">Types</a>
            
            <ul class="nav-sub-list">
            
            </ul>
            
          </li>
          <li>
            <a href="#typedefs" class="nav-label">Typedefs</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#E_HTTP_SESSION_STATE;
" class="nav-sub-label">E_HTTP_SESSION_STATE;
</a>
              </li>
      

              <li>
                <a href="#S_HTTP_SESSION;
" class="nav-sub-label">S_HTTP_SESSION;
</a>
              </li>
      

              <li>
                <a href="#SESSION_ID" class="nav-sub-label">SESSION_ID</a>
              </li>
      

              <li>
                <a href="#FUNC_HTTP_SESSION_CREATE" class="nav-sub-label">FUNC_HTTP_SESSION_CREATE</a>
              </li>
      

              <li>
                <a href="#FUNC_HTTP_SESSION_SEND" class="nav-sub-label">FUNC_HTTP_SESSION_SEND</a>
              </li>
      

              <li>
                <a href="#FUNC_HTTP_SESSION_RECEIVE" class="nav-sub-label">FUNC_HTTP_SESSION_RECEIVE</a>
              </li>
      

              <li>
                <a href="#FUNC_HTTP_SESSION_DESTORY" class="nav-sub-label">FUNC_HTTP_SESSION_DESTORY</a>
              </li>
      

              <li>
                <a href="#FUNC_HTTP_SESSION_RECEIVE_DATA" class="nav-sub-label">FUNC_HTTP_SESSION_RECEIVE_DATA</a>
              </li>
      

              <li>
                <a href="#S_HTTP_MANAGER;
" class="nav-sub-label">S_HTTP_MANAGER;
</a>
              </li>
      
            </ul>
            
          </li>
        </ul>
      </nav>
    </div>
    <div class="doc-content">
      <h2 id="Documentation" class="doc-title">Documentation</h2>
      <h3 id="includes">Includes</h3>
      

      <h4 id="tuya_cloud_types.h"><span>tuya_cloud_types.h</span></h4>
      <pre class="doc-declare"><code>#include "tuya_cloud_types.h"
</code></pre>
      <pre class="doc-comment">#include "tuya_cloud_types.h"
</pre>

      <h4 id="httpc.h"><span>httpc.h</span></h4>
      <pre class="doc-declare"><code>#include "httpc.h"
</code></pre>
      <pre class="doc-comment">#include "httpc.h"
</pre>

      <h4 id="tuya_hal_mutex.h"><span>tuya_hal_mutex.h</span></h4>
      <pre class="doc-declare"><code>#include "tuya_hal_mutex.h"
</code></pre>
      <pre class="doc-comment">#include "tuya_hal_mutex.h"
</pre>
      <h3 id="macros">Macros</h3>
      

      <h4 id="__HTTP_MANAGER_H_">Marco <span>__HTTP_MANAGER_H_</span></h4>
      <pre class="doc-declare"><code>#define __HTTP_MANAGER_H_
</code></pre>
      <pre class="doc-comment"></pre>

      <h4 id="MAX_HTTP_SESSION_NUM">Marco <span>MAX_HTTP_SESSION_NUM</span></h4>
      <pre class="doc-declare"><code>#define MAX_HTTP_SESSION_NUM   16 // max number of active session
</code></pre>
      <pre class="doc-comment"></pre>

      <h4 id="INVALID_HTTP_SESSION_ID">Marco <span>INVALID_HTTP_SESSION_ID</span></h4>
      <pre class="doc-declare"><code>#define INVALID_HTTP_SESSION_ID 4294967295 // invalid HTTP session handle
</code></pre>
      <pre class="doc-comment"></pre>

      <h4 id="MAX_HTTP_URL_LEN">Marco <span>MAX_HTTP_URL_LEN</span></h4>
      <pre class="doc-declare"><code>#define MAX_HTTP_URL_LEN       256 // max len of url
</code></pre>
      <pre class="doc-comment"></pre>
      <h3 id="functions">Functions</h3>
      
      <h3 id="vars">Vars</h3>
      

      <h4 id="S_HTTP_MANAGER">Variable <span>S_HTTP_MANAGER</span></h4>
      <pre class="doc-declare"><code>S_HTTP_MANAGER *get_http_manager_instance(VOID_T);</code></pre>
      <pre class="doc-comment">/**
 * @brief Retrieve instance of HTTP session manager
 * 
 * @note HTTP manager is singleton, multiple call to this API will return the same instance
 *
 * @return NULL on error. Instance on success, please refer to S_HTTP_MANAGER
 */</pre>
      <h3 id="consts">Consts</h3>
      
      <h3 id="types">Types</h3>
      
      <h3 id="typedefs">Typedefs</h3>
      

      <h4 id="E_HTTP_SESSION_STATE;
">Typedef <span>E_HTTP_SESSION_STATE;
</span></h4>
      <pre class="doc-declare"><code>typedef enum
{
   HTTP_FREE = 0,  // session is free
   HTTP_DISCONNECT, // session is disconnected
   HTTP_CONNECTING, // session is connecting
   HTTP_CONNECTED, // session is connected and ready to send/recv
   HTTP_UPLOADING, // session has sent data and is ready to recv
}E_HTTP_SESSION_STATE;
</code></pre>
      <pre class="doc-comment">/**
 * @brief Definition of HTTP session state
 */</pre>

      <h4 id="S_HTTP_SESSION;
">Typedef <span>S_HTTP_SESSION;
</span></h4>
      <pre class="doc-declare"><code>typedef struct
{
   /** internal HTTP session */
   http_session_t s;

   /** persistent or not */
   BOOL_T is_persistent;

   /** hdr field flags */
   http_hdr_field_sel_t flags;

   /** url content */
   CHAR_T url[MAX_HTTP_URL_LEN];

   /** http request */
   http_req_t req;

   /** session state, please refer to enum E_HTTP_SESSION_STATE */
   E_HTTP_SESSION_STATE state;
}S_HTTP_SESSION;
</code></pre>
      <pre class="doc-comment">/**
 * @brief The HTTP session's Request structure
 */</pre>

      <h4 id="SESSION_ID">Typedef <span>SESSION_ID</span></h4>
      <pre class="doc-declare"><code>typedef S_HTTP_SESSION* SESSION_ID;
</code></pre>
      <pre class="doc-comment"></pre>

      <h4 id="FUNC_HTTP_SESSION_CREATE">Typedef <span>FUNC_HTTP_SESSION_CREATE</span></h4>
      <pre class="doc-declare"><code>typedef SESSION_ID (*FUNC_HTTP_SESSION_CREATE)(IN CONST CHAR_T *url,BOOL_T is_persistent);
</code></pre>
      <pre class="doc-comment">/**
 * @brief This API is used to create HTTP session
 * 
 * @param[in] url URL of HTTP session, max len of URL is 256
 * @param[in] is_persistent Session is persistent or not
 * 
 * @return SESSION_ID on success, NULL on error
 */</pre>

      <h4 id="FUNC_HTTP_SESSION_SEND">Typedef <span>FUNC_HTTP_SESSION_SEND</span></h4>
      <pre class="doc-declare"><code>typedef OPERATE_RET (*FUNC_HTTP_SESSION_SEND)(IN CONST SESSION_ID session,IN CONST http_req_t *req,http_hdr_field_sel_t field_flags);
</code></pre>
      <pre class="doc-comment">/**
 * @brief This API is used to send HTTP session request
 * 
 * @param[in] session Session returned from the call to FUNC_HTTP_SESSION_CREATE
 * @param[in] req The http_req_t structure filled up with appropriate parameters
 * @param[in] field_flags The http_hdr_field_sel_t, OR of zero or more flags
 * 
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */</pre>

      <h4 id="FUNC_HTTP_SESSION_RECEIVE">Typedef <span>FUNC_HTTP_SESSION_RECEIVE</span></h4>
      <pre class="doc-declare"><code>typedef OPERATE_RET (*FUNC_HTTP_SESSION_RECEIVE)(SESSION_ID session, http_resp_t **resp);
</code></pre>
      <pre class="doc-comment">/**
 * @brief This API is used to recv response header from HTTP session
 * 
 * @param[in] session Session returned from the call to FUNC_HTTP_SESSION_CREATE
 * @param[in,out] resp Pointer to a pointer of type http_resp_t .The
 * structure will be allocated by the callee. Note that the caller does
 * not need to free the structure allocated and returned from this
 * API. The allocation and free is done by the callee automatically
 * 
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */</pre>

      <h4 id="FUNC_HTTP_SESSION_DESTORY">Typedef <span>FUNC_HTTP_SESSION_DESTORY</span></h4>
      <pre class="doc-declare"><code>typedef OPERATE_RET (*FUNC_HTTP_SESSION_DESTORY)(SESSION_ID session);
</code></pre>
      <pre class="doc-comment">/**
 * @brief This API is used to destroy HTTP session
 * 
 * @param[in] session Session returned from the call to FUNC_HTTP_SESSION_CREATE
 * 
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */</pre>

      <h4 id="FUNC_HTTP_SESSION_RECEIVE_DATA">Typedef <span>FUNC_HTTP_SESSION_RECEIVE_DATA</span></h4>
      <pre class="doc-declare"><code>typedef OPERATE_RET (*FUNC_HTTP_SESSION_RECEIVE_DATA)(SESSION_ID session, http_resp_t *pResp, BYTE_T** pDataOut);
</code></pre>
      <pre class="doc-comment">/**
 * @brief This API is used to recv response content from HTTP session.
 * 
 * @param[in] session Session returned from the call to FUNC_HTTP_SESSION_CREATE
 * @param[in] pResp The http_resp_t structure returned from the call to FUNC_HTTP_SESSION_RECEIVE
 * @param[in, out] pDataOut Caller allocated buffer
 * 
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */</pre>

      <h4 id="S_HTTP_MANAGER;
">Typedef <span>S_HTTP_MANAGER;
</span></h4>
      <pre class="doc-declare"><code>typedef struct
{
   /** session resources */
   S_HTTP_SESSION *session[MAX_HTTP_SESSION_NUM];
   /** exclusive access to session resources*/
   MUTEX_HANDLE mutex;

   /** session manager inited or not */
   BOOL_T inited;

   /** handler to create HTTP session */
   FUNC_HTTP_SESSION_CREATE create_http_session;
   /** handler to send HTTP session request */
   FUNC_HTTP_SESSION_SEND send_http_request;
   /** handler to recv response header from HTTP session */
   FUNC_HTTP_SESSION_RECEIVE receive_http_response;
   /** handler to destroy HTTP session */
   FUNC_HTTP_SESSION_DESTORY destory_http_session;
   /** handler to recv response content from HTTP session */
   FUNC_HTTP_SESSION_RECEIVE_DATA receive_http_data;
}S_HTTP_MANAGER;
</code></pre>
      <pre class="doc-comment">/**
 * @brief The HTTP session manager structure.
 */</pre>
    </div>
  </body>
</html>
            